package social_network.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ResourceBundle;

/**
 * Created with IntelliJ IDEA.
 * User: Vitaliy Muzalevskiy
 * Date: 13.07.13
 * Time: 16:25
 */
public class ConnectionFactorySimple implements ConnectionFactory{

    /** This value need to connect to DataBase.*/
    private static final String JDBC_URL;
    /** Login that we need to connect to concrete DataBase Server.*/
    private static final String LOGIN;
    /** Password that we need to connect to concrete DataBase Server.*/
    private static final String PASSWORD;

    static {
        final ResourceBundle config = ResourceBundle
                .getBundle("social_network.dao.dbconnection");
        JDBC_URL = config.getString("db.url");
        LOGIN = config.getString("db.login");
        PASSWORD = config.getString("db.password");
    }

    @Override
    public Connection newConnection() throws SQLException {
        return DriverManager.getConnection(JDBC_URL, LOGIN, PASSWORD);
    }

    @Override
    public void close() throws SQLException {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
